<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Autovermietung: FunctorsCarHire.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Autovermietung
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.2 -->
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_functors_car_hire_8h_source.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">FunctorsCarHire.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#ifndef FUNCTORS_CARHIRE_H</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define FUNCTORS_CARHIRE_H</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment">//a list of Cars</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="keyword">typedef</span> std::list&lt;ICar*&gt; TCars;</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="code" href="class_print_cars.html">   27</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_print_cars.html" title="A functor which is calling Print() for every Car in a list.">PrintCars</a> : <span class="keyword">public</span> std::unary_function&lt;ICar*, void&gt;{</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="code" href="class_print_cars.html#ae850daf4b2b00ea7f483e929f6512e47">   36</a></span>&#160;   <a class="code" href="class_print_cars.html#ae850daf4b2b00ea7f483e929f6512e47" title="CTor of functor PrintCars.">PrintCars</a>(std::ostream &amp;stream): mStream(stream){}</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="code" href="class_print_cars.html#a35ab52d55b8257254407f0cbe8cd63be">   42</a></span>&#160;   <span class="keywordtype">void</span> <a class="code" href="class_print_cars.html#a35ab52d55b8257254407f0cbe8cd63be" title="operator() overloaded">operator()</a>(<a class="code" href="class_i_car.html" title="Header for the ICar class.">ICar</a>* car){</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;      car-&gt;<a class="code" href="class_i_car.html#add7849531c3c3d34251abc569ca0de81" title="Prints a car including its extras.">Print</a>(mStream);</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;      mStream &lt;&lt; <span class="stringliteral">&quot;Total price: EUR &quot;</span> &lt;&lt; car-&gt;<a class="code" href="class_i_car.html#ad5a7320b095c0f3f31801dc15d17f870" title="Returns the price of a car + its extras.">GetPrice</a>() &lt;&lt; std::endl &lt;&lt; std::endl;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;   }</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;   <span class="comment">//ostream for printing</span></div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;   std::ostream &amp;mStream;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;};</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div>
<div class="line"><a name="l00056"></a><span class="lineno"><a class="code" href="class_get_cars.html">   56</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_get_cars.html" title="A functor which is calling Print() for every Car in a list.">GetCars</a> : <span class="keyword">public</span> std::unary_function&lt;ICar*, void&gt;{</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;</div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="code" href="class_get_cars.html#adeca633d9bf28d2d30e69910957434ec">   65</a></span>&#160;   <a class="code" href="class_get_cars.html#adeca633d9bf28d2d30e69910957434ec" title="CTor of functor GetCars.">GetCars</a>(std::string <span class="keyword">const</span>&amp; manufacturer, std::string <span class="keyword">const</span>&amp; type):</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;      mManufacturer(manufacturer), mType(type){}</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;</div>
<div class="line"><a name="l00076"></a><span class="lineno"><a class="code" href="class_get_cars.html#af2171a0297001d8bd9985b6df1a014b3">   76</a></span>&#160;   <span class="keywordtype">void</span> <a class="code" href="class_get_cars.html#af2171a0297001d8bd9985b6df1a014b3" title="operator() overloaded">operator()</a>(<a class="code" href="class_i_car.html" title="Header for the ICar class.">ICar</a>* car){</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;      <span class="keywordflow">if</span> (car == 0){</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;         <span class="keywordflow">throw</span> std::exception(<span class="stringliteral">&quot;invalid pointer of type ICar&quot;</span>);</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;      }</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;      <span class="comment">//if no statement is given, add all cars</span></div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;      <span class="keywordflow">if</span> (mManufacturer == <span class="stringliteral">&quot;&quot;</span> &amp;&amp; mType == <span class="stringliteral">&quot;&quot;</span>){</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;         mCars.push_back(car);</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;      }</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;      <span class="comment">//add all cars of a certain type and all manufacturers</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mManufacturer == <span class="stringliteral">&quot;&quot;</span>){</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;         <span class="keywordflow">if</span> (car-&gt;<a class="code" href="class_i_car.html#a2668750bd35cdeed2bcb5687b1f75e39" title="Returns the Type of the Car.">GetType</a>() == mType){</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;            mCars.push_back(car);</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;         }</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;      }</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;      <span class="comment">//add all cars of a certain manufacturer and all types</span></div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mType == <span class="stringliteral">&quot;&quot;</span>){</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;         <span class="keywordflow">if</span> (car-&gt;<a class="code" href="class_i_car.html#a6d5e09ba99c1c0a7cd99cb1f4f5ec543" title="Returns the manufacturer of the car.">GetManufacturer</a>() == mManufacturer){</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;            mCars.push_back(car);</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;         }</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;      }</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;      <span class="comment">//add all cars of a certain type and manufacturer</span></div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (car-&gt;<a class="code" href="class_i_car.html#a2668750bd35cdeed2bcb5687b1f75e39" title="Returns the Type of the Car.">GetType</a>() == mType &amp;&amp; car-&gt;<a class="code" href="class_i_car.html#a6d5e09ba99c1c0a7cd99cb1f4f5ec543" title="Returns the manufacturer of the car.">GetManufacturer</a>() == mManufacturer){</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;         mCars.push_back(car);</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;      }</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;   }</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;</div>
<div class="line"><a name="l00108"></a><span class="lineno"><a class="code" href="class_get_cars.html#aa36143286f1e96acced896b2706b5da5">  108</a></span>&#160;   TCars <a class="code" href="class_get_cars.html#aa36143286f1e96acced896b2706b5da5" title="getter for retrieving the list of cars">GetCarList</a>()<span class="keyword"> const</span>{</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;      <span class="keywordflow">return</span> mCars;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;   }</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;   <span class="comment">//car manufacturer</span></div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;   std::string mManufacturer;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;   <span class="comment">//car type</span></div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;   std::string mType;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;   <span class="comment">//list of cars that match witch the search strings</span></div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;   TCars mCars;</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;};</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><b>FunctorsCarHire.h</b></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.2 </li>
  </ul>
</div>
</body>
</html>
